package com.dhc.service.config;

import com.dhc.service.utils.result.Result;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author kazu
 * @Date 2023/10/08 0:45
 * @Version 1.0
 */
@SuppressWarnings({"all"})
@ControllerAdvice
@Configuration
public class VaildExceptionConfig {
	private static final Logger logger = Logger.getLogger(VaildExceptionConfig.class);
	
	@ResponseBody
	@ExceptionHandler(MethodArgumentNotValidException.class)
	public Result throwCustomException(MethodArgumentNotValidException ex) {
		Result error = Result.error();
		error.setCode(401);
		error.setMessage("401");
		return error;
	}
}
